//Pietras93OS
//Timer
//pietras93@gmail.com
//

#include <system.h>

int timer_ticks = 0;

void timer_handler2(struct regs *r)
{
    timer_ticks++;

    if (timer_ticks % 18 == 0)
    {
        //puts("One second has passed\n");
    }
}

void sleep(int sec)
{
	timer_ticks++;
	
	if (timer_ticks % 18*sec == 0)
	{
		return 0;
	}
}

void timer_wait(int ticks)
{
    unsigned long eticks;

    eticks = timer_ticks + ticks;
    while(timer_ticks < eticks);
}

void timer_install()
{
    irq_install_handler(0, timer_handler2);
	puts("Timer installed!");
}
